package com.yaiys.jvm;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;

public class QueueTask  implements Runnable{

    private CountDownLatch countDownLatch;
    private String name;
    private int needTime;
    public QueueTask(CountDownLatch countDownLatch,String name,int needTime){
        this.name=name;
        this.needTime=needTime;
        this.countDownLatch=countDownLatch;
    }
    @Override
    public void run() {
        System.out.println("开始去"+name+"对中。。。。。。。。。。。。。。。");
        try {
            Thread.sleep(needTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            if (countDownLatch!=null){
                System.out.println("干完了-------------"+name);
                countDownLatch.countDown();
            }
        }
    }


}
